a = input("Введите скобочную последовательность: ")
k = []
x = True
for i in a:
    if i in "({[<":
        k.append(i)
    elif i in ")}]>":
        if not k:
            x = False
            break
        c = k.pop()
        if c == "(" and i == ")":
            continue
        if c == "{" and i == "}":
            continue
        if c == "[" and i == "]":
            continue
        if c == "<" and i == ">":
            continue
        x = False
        break
if x and len(k)==0:
    print(True)
else:
    print(False)
